//
//  EmailAttacheContent.m
//  xjairOA
//
//  Created by apple on 16-1-19.
//  Copyright (c) 2016年 net. All rights reserved.
//

#import "EmailAttacheContent.h"

@implementation EmailAttacheContent
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title=@"附件内容";
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    //NSLog(@"#######%@",documentsDirectory);
    //NSLog(@"%@",documentsDirectory);
    NSString *docPath = [documentsDirectory stringByAppendingString:@"/1.doc"];
    //NSLog(@"#######%@",docPath);
    NSString * urlAsString = @"http://172.16.3.126:8080/iosServer/attaches/1.doc";
    NSURL * url = [NSURL URLWithString:urlAsString];
    NSURLRequest * request = [NSURLRequest requestWithURL:url];
    NSError * error = nil;
    NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
    if(data !=nil){
        // NSLog(@"下载成功");
        if([data writeToFile:docPath atomically:YES]){
            //  NSLog(@"保存成功");
            
        }
        else{
            // NSLog(@"保存失败");
        }
    }else{
        NSLog(@"%@",error);
    }
    NSURL * url1 = [NSURL fileURLWithPath:docPath];
    NSURLRequest *request1 = [NSURLRequest requestWithURL:url1];
    [self.webView loadRequest:request1];


}

@end
